from ..providers.qwen import Qwen
from ..providers.volcengine import VolcEngine
from ..providers.deepseek import Deepseek

class AIGenerator:
    # 初始化 AI 抽象层
    def __init__(self, provider, api_key):
        self.provider = provider
        self.api_key = api_key
        self.ai = self._create_ai_instance()
    
    # 根据 provider 创建具体的 AI 实例
    def _create_ai_instance(self):
        if self.provider == "qwen":
            return Qwen(self.api_key)
        elif self.provider == "volcengine":
            return VolcEngine(self.api_key)
        elif self.provider == "deepseek":
            return Deepseek(self.api_key)
        else:
            raise ValueError(f"Unsupported provider: {self.provider}")
    
    # 生成图片
    def generate_image(self, prompt, style, image_path):
        return self.ai.generate_image(prompt, style, image_path)

    # 识别图片
    def recognize_image(self, prompt, image_path):
        return self.ai.recognize_image(prompt, image_path)
    
    # 图片画面扩展
    def extend_image(self, prompt, image_path):
        return self.ai.extend_image(prompt, image_path)
    
    # 图像局部重绘
    def redraw_image(self, prompt, base_image_path, mask_image_path):
        return self.ai.redraw_image(prompt, base_image_path, mask_image_path)
    
    # 图像风格重绘
    def redraw_style(self, prompt, image_path):
        return self.ai.redraw_style(prompt, image_path)
    
    # 科学问答
    def science_chat(self, prompt):
        return self.ai.science_chat(prompt)


